pp108 : Starting a Transaction

Starting a Transaction

This topic describes the process of starting a transaction.


WS-AppServer provides flexibility to handle transactions implicitly (automatically) or explicitly. In an implicit transaction, WS-AppServer starts the transaction automatically along with the Process Platform service. In an explicit transaction, WS-AppServer starts the transaction based on the custom application logic provided. This scenario is more relevant when WS-AppServer functions in an embedded mode within an application.

WS-AppServer provides APIs that contain methods to start a transaction in either of the modes (implicit/explicit). For details on the APIs and the respective methods, refer WS-AppServer SDK.

To start a transaction, do the following:

  1. Compile the Java code for the method in LDAP.
    public static ITEM Test(String code) throws Exception { try { BSF.startTransaction(String transactionID); //Provide logic here; BSF.commitTransaction(String transactionID) }catch (Exception e) { //Provide abortTransaction logic, when commitTransaction fails. Throw e; } return itemObj ; }

  2. In the implementation of the method, set the start parameter to "true", as shown in the following sample:
    <implementation type="BsfJavaCall">
        <transaction>
            <start>true</start>
            <!-- If you want to start the transaction through the application, set this parameter to 'false' -->
        </transaction>
        <class>ITEM</class>
        <method dt="java:ITEM" scope="out">Test</method>
        <parameters>
            <key dt="string" scope="in"/>
        </parameters>
    </implementation>
    

    Note: If you omit the transaction element or do not specify anything, WS-AppServer will start the transaction automatically by default.
  3. Run the program to start the transaction.

Related concepts

Parallel Transactions

Related reference

Retrying a Transaction

Related information

Managing Transactions Using WS-AppServer